class WebsitesinfsController < ApplicationController
before_filter :authorize
    layout "websitesinfo"
  
      active_scaffold :websitesinf do |config|
  config.label = "Websites Information"
config.show.link.label = "Show Detail"  
config.show.link.type = :record
config.show.link.inline = true
  config.show.link.position = :after 

 #   config.columns = [:name,:editorname1,:seditorname1]
  	  config.columns = [:name,:description1,:url1,:editorname1,:seditorname1,:mission1,:ecweekly1,:last_accessed_at,:last_accessed_user,:last_updated_at,:last_updated_user]	
  config.list.columns.exclude :description1, :url1, :mission1, :ecweekly1 	

# config.actions.swap :search, :live_search
   
		 config.columns[:name].label ="Website Name"
		 config.columns[:description1].label ="Website Description"
		 config.columns[:url1].label ="Website URL"
		 config.columns[:editorname1].label ="Name of Editor"	  	 
		 config.columns[:seditorname1].label ="Name of Sub Editor"
		 config.columns[:mission1].label ="Website mission"	  	 
		 config.columns[:ecweekly1].label ="Editors weekly comment"	

 
		    config.nested.add_link("Websites's tasks", [:tasksdescs]) 
   		 config.columns[:tasksdescs].search_sql = "CONCAT(tasksdescs.name,tasksdescs.ecomments1)"    
		 config.search.columns << :tasksdescs
	config.nested.shallow_delete = true	
#   config.actions.exclude :nested			 
    config.columns[:description1].form_ui = :textarea
    config.columns[:description1].options = {:rows => 90, :cols => 150}


    config.columns[:ecweekly1].form_ui = :textarea
    config.columns[:ecweekly1].options = {:rows => 90, :cols => 150}
    
#   		 config.columns[:subtasksdescs].search_sql = "CONCAT(subtasksdescs.descocont1,subtasksdescs.commocont1,subtasksdescs.conturl1,subtasksdescs.searterm1,subtasksdescs.uname1,subtasksdescs.upwd1)"    
#		     config.search.columns << :subtasksdescs
    config.subform.columns.exclude :description1, :url1, :mission1, :ecweekly1

    config.create.columns.exclude(:description1, :url1, :mission1, :ecweekly1,:last_accessed_at,:last_accessed_user,:last_updated_at,:last_updated_user)  
    config.create.columns.add_subgroup "Detail Information"  do |group|       
       	group.add(:description1, :url1, :mission1, :ecweekly1) 
       	end     
       	
    config.update.columns.exclude(:description1, :url1, :mission1, :ecweekly1,:last_accessed_at,:last_accessed_user,:last_updated_at,:last_updated_user)  
    config.update.columns.add_subgroup "Detail Information"  do |group|       
    	group.add(:description1, :url1, :mission1, :ecweekly1)  
    	end  

    config.show.columns.exclude(:name,:editorname1,:seditorname1)       	
  config.show.label = "Show Detail"

# config.subform.columns = [:description1, :url1, :mission1, :ecweekly1] config.subform.columns = [:name1,:editorname1,:seditorname1]
		 
  end

  def show
  super

    @websitesinf = Websitesinf.find(params[:id])
    @websitesinf.last_accessed_user = User.find(session[:user_id]).name + " action show"
    @websitesinf.last_accessed_at = Time.now
    @websitesinf.save

  end

    def update

  super

    @websitesinf = Websitesinf.find(params[:id])
    @websitesinf.last_updated_user = User.find(session[:user_id]).name + " action update"
    @websitesinf.last_updated_at = Time.now
    @websitesinf.save

  end 
  
  def do_edit
  super

    @websitesinf = Websitesinf.find(params[:id])
    @websitesinf.last_accessed_user = User.find(session[:user_id]).name + " action edit"
    @websitesinf.last_accessed_at = Time.now
    @websitesinf.save

  end
  
  def do_nested
  super

    @websitesinf = Websitesinf.find(params[:id])
    @websitesinf.last_accessed_user = User.find(session[:user_id]).name + " action tasks"
    @websitesinf.last_accessed_at = Time.now
    @websitesinf.save

  end  
end
